package nl.unimaas.micc.eventSnookerTest.domain;

import nl.unimaas.micc.eventSnookerTest.math.Vector3D;
import nl.unimaas.micc.eventSnookerTest.simulation.physics.BallMotion;
import nl.unimaas.micc.eventSnookerTest.simulation.physics.Physics;

public class Ball
{
	public enum BallState
	{
		RESTING(Physics.getRestingMotion()), 
		SLIDING(Physics.getSlidingMotion()), 
		ROLLING(Physics.getRollingMotion());
		
		BallState(BallMotion motion)
		{
			this.motion = motion;
		}
		public BallMotion getMotion()
		{
			return motion;
		}
		private BallMotion motion;
	}

	public Vector3D getAngularVelocity()
	{
		return angularVelocity;
	}

	public void setAngularVelocity(Vector3D av)
	{
		this.angularVelocity = av;
	}

	public double getRadius()
	{
		return radius;
	}

	public void setRadius(double d)
	{
		this.radius = d;
	}

	public Vector3D getPosition()
	{
		return position;
	}

	public void setPosition(Vector3D position)
	{
		this.position = position;
	}

	public Vector3D getVelocity()
	{
		return velocity;
	}

	public void setVelocity(Vector3D velocity)
	{
		this.velocity = velocity;
	}

	public double getTime()
	{
		return time;
	}

	public void setTime(double time)
	{
		this.time = time;
	}

	public String toString()
	{
		return "[t:" + time + ", p:" + position + ", v:" + velocity + ", |v|:"
				+ velocity.getLength() + ", av:" + angularVelocity + "|u|:"+Physics.getRelativeVelocity(this).getLength()+"Mass: "+this.getMass()+"]";
	}
	@Override
	public Object clone()
	{
		Ball b2 = new Ball();
		b2.angularVelocity = angularVelocity;
		b2.position = position;
		b2.radius = radius;
		b2.time = time;
		b2.velocity = velocity;
		b2.state = state;
		return b2;
	}

	public BallState getState()
	{
		return state;
	}

	public void setState(BallState state)
	{
		this.state = state;
	}

	public void setMass(double mass) {
		this.mass = mass;
	}

	public double getMass() {
		return mass;
	}

	private Vector3D position;
	private Vector3D velocity;
	private Vector3D angularVelocity;
	private double time;
	private double radius;
	private double mass;
	private BallState state = BallState.RESTING;
}
